package com.jas.logic;
//@author A0098803W
import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.jas.common.CommandFormatException;
import com.jas.common.DateFormatException;
import com.jas.common.Language;
import com.jas.common.Notification;
import com.jas.storage.StorageAPI;
import com.jas.storage.StorageException;
//@author A0098803W
/**
 * This class handles test for the <code>notify</code> and <code>sms</code> command.
 *
 */
public class NotifyTest {

	@Before
	public void setUp() throws Exception {
		Language.loadLanguageFile();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testNotifyCommand() throws CommandFormatException, StorageException, DateFormatException {
		Logic logic = new Logic();
		LogicAPI logicApi = new LogicAPI(logic);
		Notification newNotification=logicApi.add("2015", "yyyy", "This is a test message.");
		Notification newNotification2=logicApi.add("04/2015", "MM/yyyy", "This is a test message.");
		Notification newNotification3=logicApi.add("30/04/2015", "dd//MM/yyyy", "This is a test message.");
		Notification newNotification4=logicApi.add("30/04/2015/23:59", "dd/MM/yyyy/HH:mm", "This is a test message.");
		assertTrue(newNotification.getMessage().equalsIgnoreCase("This is a test message."));
		assertTrue(newNotification2.getMessage().equalsIgnoreCase("This is a test message."));
		assertTrue(newNotification3.getMessage().equalsIgnoreCase("This is a test message."));
		assertTrue(newNotification4.getMessage().equalsIgnoreCase("This is a test message."));
		}
	
	@Test
	public void testSMSCommand() throws CommandFormatException, StorageException, DateFormatException {
		Logic logic = new Logic();
		LogicAPI logicApi = new LogicAPI(logic);
		logicApi.updateGateway("http://www.yahoo.com");
		assertTrue(StorageAPI.getGatewaySettings().equalsIgnoreCase("http://www.yahoo.com"));
		assertFalse(StorageAPI.getGatewaySettings().equalsIgnoreCase("http://www.google.com"));
		}

}
